﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RelationExpertSystem.Relation
{
    public class Niece : RelationBase
    {
        private static Niece _singleton = new Niece();
        public static Niece Instance
        {
            get { return _singleton; }
        }

        private Niece() { }

        public override bool IsRelated(Person a, Person b)
        {
            // b is a's Niece IFF b is female AND one of b's parents is a's sibling
            return (b.Sex == Sex.Female &&
                (a.KnownRelation(Sibling.Instance, b.Mother) ||
                a.KnownRelation(Sibling.Instance, b.Father)));
        }

        public override IEnumerable<IRelation> GetDependencies()
        {
            return new HashSet<IRelation>(new IRelation[] { Sibling.Instance, Mother.Instance, Father.Instance });
        }
    }
}
